﻿#if DEBUG

using System;
using System.Diagnostics;
using System.Text;

namespace UDS
{
    /// <summary>
    /// Provide a trace listener to throw exceptions for asset failure.
    /// </summary>
    internal class AssetTraceListener : TraceListener
    {
        public override void Fail(string message)
        {
            this.Fail(message, null);
        }

        public override void Fail(string message, string detailMessage)
        {
            var sb = new StringBuilder();
            sb.Append("Assert Failure: ");
            sb.Append(message);
            if (detailMessage != null)
            {
                sb.Append(" ");
                sb.Append(detailMessage);
            }

            throw new InvalidOperationException(sb.ToString());
        }

        public override void Write(string message)
        {
            // Ignore the message.
        }

        public override void WriteLine(string message)
        {
            // Ignore the message.
        }
    }
}

#endif